---@class GT.timer_local
---@field loc_timeId Int32 本地计时器ID
GT.timer_local=class()

---@class timer_local_data
---@field delay Float 延迟
---@field callback function 回调函数
---@field isloop boolean 是否循环

---本地计时器初始化
---@param data timer_local_data
function GT.timer_local:ctor(data)
    
    self.delay=data.delay
    self.callback=data.callback
    self.isloop=data.isloop
    if self.isloop then
        self.loc_timeId=self:add_local_repeat_timer()
    else
        self.loc_timeId=self:add_local_timer()
    end
end
---删除本地计时器
function GT.timer_local:dtor()
    self:cancel_local_timer()
end

--- 添加本地计时器
---@return Int32
function GT.timer_local:add_local_timer()
    
    return game_api.add_local_timer(self.delay,self.callback)
end

--- 添加本地循环计时器
---@return Int32
function GT.timer_local:add_local_repeat_timer()
    return game_api.add_local_repeat_timer(self.delay,self.callback)
end

--- 取消本地计时器
---@param timer_id Int32 计时器编号
function GT.timer_local:cancel_local_timer()
    game_api.cancel_local_timer(self.loc_timeId)
end
